package gates;

import register.Register;
import gates.FunctionGate;


 /**
 * Nand all inputs: This operator flips all states except the first state. 
 * Surrounded by two hadamard transforms makes the inversion about mean.
 * Flips all states in vector space orthogonal to vector space of first state. 
 * @author Jan Zaucha
 *
 */
public class NandAllFunction extends FunctionGate {




	/**
	 * Protected constructor to create an instance of this object
	 * 
	 */
	protected NandAllFunction(){

	}


	/**
	 * Returns the name of the gate regardless of representation.
	 */
	public String getName() {
		return "Nand All";
	}

	/**
	 * Flips all states except 0 state
	 *
	 * @param r the register 
	 */
	public void apply(Register r) {

		for(int i=1; i<r.getNumStates(); i++){
			r.getElement(0, i).negate();
		}

	}



}
